package formularios;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import relatorio.relatAluno;
import relatorio.relatLivro;
import relatorio.relatLocacao;

public final class Relatorios extends javax.swing.JFrame {

    public Relatorios() {
       initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ordenação = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jB_emitir = new javax.swing.JButton();
        jB_voltar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jR_aluno = new javax.swing.JRadioButton();
        jR_livros = new javax.swing.JRadioButton();
        jR_locação = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("SGB (Sistema Gerenciador da Biblioteca)");

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 3, true), "Relatorios", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), new java.awt.Color(0, 102, 0))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(0, 102, 0));

        jB_emitir.setBackground(new java.awt.Color(255, 255, 255));
        jB_emitir.setForeground(new java.awt.Color(0, 102, 0));
        jB_emitir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura4.png"))); // NOI18N
        jB_emitir.setText("Emitir");
        jB_emitir.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 102, 0), java.awt.Color.white), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
        jB_emitir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_emitirActionPerformed(evt);
            }
        });

        jB_voltar.setBackground(new java.awt.Color(255, 255, 255));
        jB_voltar.setForeground(new java.awt.Color(0, 102, 0));
        jB_voltar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Png/Figura6.png"))); // NOI18N
        jB_voltar.setText("Voltar");
        jB_voltar.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 102, 0), java.awt.Color.white), new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 0), 1, true)));
        jB_voltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_voltarActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/formularioPrincipal/mundo-na-palma-da-mão11 cópia.png"))); // NOI18N

        jR_aluno.setBackground(new java.awt.Color(204, 255, 204));
        ordenação.add(jR_aluno);
        jR_aluno.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jR_aluno.setForeground(new java.awt.Color(0, 102, 0));
        jR_aluno.setText("Aluno");
        jR_aluno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jR_alunoActionPerformed(evt);
            }
        });

        jR_livros.setBackground(new java.awt.Color(204, 255, 204));
        ordenação.add(jR_livros);
        jR_livros.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jR_livros.setForeground(new java.awt.Color(0, 102, 0));
        jR_livros.setText("Livros");
        jR_livros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jR_livrosActionPerformed(evt);
            }
        });

        jR_locação.setBackground(new java.awt.Color(204, 255, 204));
        ordenação.add(jR_locação);
        jR_locação.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jR_locação.setForeground(new java.awt.Color(0, 102, 0));
        jR_locação.setText("Emprestimos");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(116, 116, 116)
                .addComponent(jB_voltar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jB_emitir, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 156, Short.MAX_VALUE)
                .addComponent(jLabel1))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jR_locação)
                    .addComponent(jR_livros)
                    .addComponent(jR_aluno))
                .addContainerGap(375, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addComponent(jR_aluno)
                .addGap(18, 18, 18)
                .addComponent(jR_livros)
                .addGap(12, 12, 12)
                .addComponent(jR_locação)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jB_voltar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jB_emitir))
                        .addContainerGap())
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-577)/2, (screenSize.height-387)/2, 577, 387);
    }// </editor-fold>//GEN-END:initComponents

    private void jB_voltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_voltarActionPerformed
        dispose();
    }//GEN-LAST:event_jB_voltarActionPerformed

    private void jB_emitirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_emitirActionPerformed
        if (jR_aluno.isSelected()) {
            try {
                verificaAluno();
            } catch (Exception ex) {
                Logger.getLogger(Relatorios.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else if (jR_livros.isSelected()) {
            try {
                verificaLivro();
            } catch (Exception ex) {
                Logger.getLogger(Relatorios.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else if (jR_locação.isSelected()) {
            try {
                verificalocacao();
            } catch (Exception ex) {
                Logger.getLogger(Relatorios.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Selecione algum item!");
        }
    }//GEN-LAST:event_jB_emitirActionPerformed

    private void jR_alunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jR_alunoActionPerformed
    }//GEN-LAST:event_jR_alunoActionPerformed

    private void jR_livrosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jR_livrosActionPerformed
    }//GEN-LAST:event_jR_livrosActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB_emitir;
    private javax.swing.JButton jB_voltar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jR_aluno;
    private javax.swing.JRadioButton jR_livros;
    private javax.swing.JRadioButton jR_locação;
    private javax.swing.ButtonGroup ordenação;
    // End of variables declaration//GEN-END:variables

    public void verificaLivro() throws Exception {
       
            new relatLivro().geraRelatorio();
        

       
    }

    public void verificaAluno() throws Exception {
       
            new relatAluno().geraRelatorio();

        
    }

    public void verificalocacao() throws Exception {
       
            new relatLocacao().geraRelatorio();

       


    }
}
